package com.itheima.reggie.mapper;

import com.itheima.reggie.dto.SetmealDto;
import com.itheima.reggie.entity.Setmeal;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface SetmealMapper {

    @Select("SELECT COUNT(*) FROM setmeal WHERE category_id=#{id}")
    long findSetmealCountByCateGoryId(long id);
    //保存新增套餐信息
    @Insert("insert into setmeal values(null,#{categoryId},#{name},#{price},#{status},#{code},#{description},#{image},#{createTime},#{updateTime},#{createUser},#{updateUser},0)")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    void save(SetmealDto setmealDto);
    //根据name查找套餐
    List<Setmeal> findByName(String name);
    //查询套餐状态为1，出售的总数
    Long queryDishWithStatus(@Param("ids") List<Long> ids);
    //根据id删除套餐
    void DeleteByIds(@Param("ids") List<Long> ids);
    /*批量起售停售套餐*/
    void UpdateStatusByIds(@Param("ids") List<Long> ids, @Param("status") Integer status);
    /*数据回显*/
    @Select("select * from setmeal where id=#{id}")
    SetmealDto findBySetmealId(Long id);
    /*修改套餐*/
    void updateById(SetmealDto setmealDto);
}
